package com.cg.design.graphicdesignpattern.singleton;

import org.junit.Test;

/**
 * 测试类
 *
 * @program: LeetCode->SingletonTest
 * @description: 测试类
 * @author: cg
 * @create: 2022-03-19 15:32
 **/
public class SingletonTest {

    @Test
    public void testSingleton() {
        System.out.println("Start.");
        Singleton s1 = Singleton.getInstance();
        Singleton s2 = Singleton.getInstance();
        if (s1 == s2) {
            System.out.println("s1与s2是相同的实例");
        } else {
            System.out.println("s1与s2是不同的实例");
        }
        System.out.println("End.");

        System.out.println();
        System.out.println("Start.");
        for (int i = 0; i < 10; i++) {
            System.out.println(i + ":" + TicketMaker.getInstance().getNextTicketNumber());
        }
        System.out.println("End.");

        System.out.println();
        System.out.println("Start.");
        for (int i = 0; i < 9; i++) {
            Triple triple = Triple.getInstance(i%3);
            System.out.println(i + ":" + triple);
        }
        System.out.println("End.");
    }

}
